//
//  BaseObject.m
//  MoGuRadio
//
//  Created by dlios on 15/6/8.
//  Copyright (c) 2015年 mogu.com 蘑菇科技. All rights reserved.
//

#import "BaseObject.h"

@implementation BaseObject

- (instancetype)initWithDictionary:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}



+ (NSMutableArray *)modelArrWithDics:(NSMutableArray *)dicArr
{
    
    NSMutableArray *allPageArr = [NSMutableArray array];
    
    for (NSDictionary *allPageDic in dicArr) {
        
        @autoreleasepool {
            if ([allPageDic isKindOfClass:[NSDictionary class]]) {
                
                id allPage = [[self class] objectWithDictionary:allPageDic];
                
                [allPageArr addObject:allPage];
            } else {
                NSLog(@"不符合方法要求, 请检查数据源"
                      "参数中的所有元素都必须是全部的字典信息");
        }
    }
}
    
    if (allPageArr.count == 0) {
        
        NSLog(@"数组个数为空, 请检查数据源");
}
    
    
    return allPageArr;
}

+ (instancetype)objectWithDictionary:(NSDictionary *)dic
{
    id object = [[[self class] alloc] initWithDictionary:dic];
    return object;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

- (id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}



@end
